package com.ruoyi.finance.welfareRecharge.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.finance.welfareRecharge.domain.FiWelfareRecharge;
import com.ruoyi.finance.welfareRecharge.service.IFiWelfareRechargeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 福利充值Controller
 * 
 * @author wangmh
 * @date 2023-09-17
 */
@RestController
@RequestMapping("/finance/welfareRecharge")
public class FiWelfareRechargeController extends BaseController
{
    @Autowired
    private IFiWelfareRechargeService fiWelfareRechargeService;

    /**
     * 查询福利充值列表
     */
    @PreAuthorize("@ss.hasPermi('finance:welfareRecharge:list')")
    @GetMapping("/list")
    public TableDataInfo list(FiWelfareRecharge fiWelfareRecharge)
    {
        startPage();
        List<FiWelfareRecharge> list = fiWelfareRechargeService.selectFiWelfareRechargeList(fiWelfareRecharge);
        return getDataTable(list);
    }

    /**
     * 导出福利充值列表
     */
    @PreAuthorize("@ss.hasPermi('finance:welfareRecharge:export')")
    @Log(title = "福利充值", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FiWelfareRecharge fiWelfareRecharge)
    {
        List<FiWelfareRecharge> list = fiWelfareRechargeService.selectFiWelfareRechargeList(fiWelfareRecharge);
        ExcelUtil<FiWelfareRecharge> util = new ExcelUtil<FiWelfareRecharge>(FiWelfareRecharge.class);
        return util.exportExcel(list, "福利充值数据");
    }

    /**
     * 获取福利充值详细信息
     */
    @PreAuthorize("@ss.hasPermi('finance:welfareRecharge:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fiWelfareRechargeService.selectFiWelfareRechargeById(id));
    }

    /**
     * 新增福利充值
     */
    @PreAuthorize("@ss.hasPermi('finance:welfareRecharge:add')")
    @Log(title = "福利充值", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FiWelfareRecharge fiWelfareRecharge)
    {
        return toAjax(fiWelfareRechargeService.insertFiWelfareRecharge(fiWelfareRecharge));
    }

    /**
     * 修改福利充值
     */
    @PreAuthorize("@ss.hasPermi('finance:welfareRecharge:edit')")
    @Log(title = "福利充值", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FiWelfareRecharge fiWelfareRecharge)
    {
        return toAjax(fiWelfareRechargeService.updateFiWelfareRecharge(fiWelfareRecharge));
    }

    /**
     * 删除福利充值
     */
    @PreAuthorize("@ss.hasPermi('finance:welfareRecharge:remove')")
    @Log(title = "福利充值", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fiWelfareRechargeService.deleteFiWelfareRechargeByIds(ids));
    }
}
